#!/bin/bash
yum -y install httpd
VERSION=$(cat /etc/centos-release|awk -F' ' '{if(NR==1) print $4}'|cut -d. -f1)
if [ "$VERSION" == "6" ];then
        chkconfig --add httpd
        chkconfig httpd on
        service httpd start
	iptables -I INPUT 1 -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
	iptables -I INPUT 1 -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
	service iptables restart
	setenforce 0
fi
if [ "$VERSION" == "7" ];then
        systemctl enable httpd
        systemctl start httpd
	setenforce 0
  #if firewalld open ,you can add http and https service 
	firewall-cmd --permanent --zone=public --add-service=http
	firewall-cmd --permanent --zone=public --add-service=https
	firewall-cmd --reload
fi
    
